package ink.lovejinhu.leetcodeMatch;

import java.util.HashSet;

/**
 * @Author: jin
 * @Date: 2021/9/5 10:39
 * @Version: V1.0
 * @Slogan: Great people are not born great, but show their greatness in the process of growing up
 **/
public class Solution_5864 {
    /**
     * 游戏中弱角色的数量
     * [[7,7],[1,2],[9,7],[7,3],[3,10],[9,8],[8,10],[4,3],[1,5],[1,5]]
     *
     * @param properties
     * @return
     */
    public int numberOfWeakCharacters(int[][] properties) {

        HashSet<Integer> res = new HashSet<>();

        for (int i = 0; i < properties.length; i++) {
            if (res.contains(i)) {
                continue;
            }
            for (int j = 0; j < properties.length; j++) {
                int attack0 = properties[i][0];
                int defence0 = properties[i][1];

                int attack1 = properties[j][0];
                int defence1 = properties[j][1];
                if (i != j) {
                    if (attack1 < attack0 && defence1 < defence0) {
                        res.add(j);
                    }
                    if (attack1 > attack0 && defence1 > defence0) {
                        res.add(i);
                    }
                }
            }


        }
        /**
         * [0, 1, 3, 7, 8, 9]
         * [1, 3, 5, 6, 7, 8, 9]
         */
//        System.out.println(res);
        return res.size();
    }

    public static void main(String[] args) {
        Solution_5864 solution_5864 = new Solution_5864();
        int[][] pro = {{7, 7}, {1, 2}, {9, 7}, {7, 3}, {3, 10}, {9, 8}, {8, 10}, {4, 3}, {1, 5}, {1, 5}};
        int i = solution_5864.numberOfWeakCharacters(pro);
        System.out.println(i);
    }
}
